package com.nf.xiaomi.service.impl;

import com.nf.xiaomi.dao.AddressDao;
import com.nf.xiaomi.dao.UserDao;
import com.nf.xiaomi.dao.impl.AddressDaoImpl;
import com.nf.xiaomi.dao.impl.UserDaoImpl;
import com.nf.xiaomi.entity.AddressEntity;
import com.nf.xiaomi.service.AddressService;

import java.util.List;

public class AddressServiceImpl implements AddressService {
    AddressDao addressDao = new AddressDaoImpl();
    UserDao userDao = new UserDaoImpl();

    @Override
    public List<AddressEntity> getAll() {
        return addressDao.getAll();
    }

    @Override
    public List<AddressEntity> getAll(Long account) {
        Integer userID = userDao.getAllID(account);
        return addressDao.getAll(userID);
    }

    @Override
    public List<AddressEntity> getAll(Integer addressID) {
        return addressDao.getAllAddress(addressID);
    }

    @Override
    public int insert(AddressEntity addressEntity) {
        return addressDao.insert(addressEntity);
    }

    @Override
    public int update(AddressEntity addressEntity) {
        return addressDao.update(addressEntity);
    }

    @Override
    public int delete(Integer addressId) {
        return addressDao.delete(addressId);
    }
}
